package com.atguigu.dao.impl;

import com.atguigu.bean.Order;
import com.atguigu.bean.OrderItem;
import com.atguigu.dao.BaseDao;
import com.atguigu.dao.OrderDao;

import java.util.List;

/**
 * @ Author:任留辉
 * @ Description:
 * @ Date:Created in 9:01 2021/3/21 0021
 */
public class OrderDaoImpl extends BaseDao<Order> implements OrderDao {
    @Override
    public void saveOrder(Order order) {
        String sql = "insert into bs_order values(?,?,?,?,?,?)";
        update(sql, order.getId(), order.getCreateTime(), order.getTotalCount(), order.getTotalAmount(), order.getStatus(), order.getUserId());
    }

    @Override
    public List<Order> getMyOrder(Integer userId) {
        String sql = "select * from bs_order where userId = ?";
        return getBeanList(Order.class, sql, userId);
    }

    @Override
    public void updateStatus(String orderId, int status) {
        String sql = "update bs_order set status = ? where id = ?";
        update(sql, status, orderId);
    }

    @Override
    public List<Order> getAllOrder() {
        String sql = "select * from bs_order";
        return getBeanList(Order.class, sql);
    }
}
